#include <iostream>

void test_int();
void test_float();
void test_sizet();

int main(int argc, char *argv[]) {
  std::cout << "==== ch02 p01 ====" << std::endl;
  test_int();
  test_float();
  test_sizet();
  return 0;
}

void test_int() {
  short int a = 10;
  int b = 20;
  long int c = 30;
  long long int d = 40;
  std::cout << "short int: " << sizeof(a) << std::endl;
  std::cout << "int: " << sizeof(b) << std::endl;
  std::cout << "long int: " << sizeof(c) << std::endl;
  std::cout << "long long int: " << sizeof(d) << std::endl;

  // 可以使用单引号 ' 作为数字的分隔符
  unsigned short a1 = 0b0010'0100;
  int b1 = 0123;
  int c1 = 123;
  unsigned long long d1 = 0xFFFF'FFFF'FFFF'FFFF;
  printf("a1 = %hu; b1 = %d; c1 = %d; d1 = %llu\n", a1, b1, c1, d1);
}

void test_float() {
  float a1 = 3.14f;
  double b1 = 3.14;
  long double c1 = 3.14l;

  double x = 3.14e-2; // 等于 0.0314
  double y = 3.14e+2; // 等于 314.0
  double y2 = 3.14e2; // 可以省略+号, 等于 314.0
}

void test_sizet() {
  double i1 = 10;
  size_t s1 = sizeof(float);
  std::size_t s2 = sizeof(i1);
  std::cout << "s1 = " << s1 << ", s2 = " << s2 << std::endl;
}
